<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.util.*" session="true"%>
<%@ page import = "pe.com.deuda.bd.dao.ConsultaDAO"%>
<%@ page import = "pe.com.deuda.bd.model.Reclamo"%>
<%@ page import = "java.util.ArrayList"%>
<%@ page import = "java.util.List"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<script>
       function seleccionar(codigo, ix){
           if (document.frmReclamo.reclamo.length!=undefined ){
            for(var i = 0; i < document.frmReclamo.reclamo.length; i++){
                if(document.frmReclamo.reclamo[i].type == "checkbox")    {
                    if (i==ix){
                        if (document.frmReclamo.reclamo[i].checked==true){
                            document.frmReclamo.codigo.value=codigo;
                        }
                        else{
                            document.frmReclamo.codigo.value='';
                        }
                    }
                    else{
                        document.frmReclamo.reclamo[i].checked=false;
                    }
                }
            }
           }
           else{
               document.frmReclamo.codigo.value=codigo;
           }
       }

    function submitform()
    {
        document.forms["frmReclamo"].submit();
    }
</script>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="/WebDeudas/css/estilo.css" rel="stylesheet" type="text/css" />
        <title>Resultado Busqueda Reclamo</title>
    </head>
    <body>
        <p>&nbsp;</p>
        <table width="80%">
            <tr>
                <td width="30%"></td>
                <td width="50%">&nbsp;</td>
                <td width="20%">Bienvenido <%=session.getAttribute("nombre") %> ! </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td> </td>
                <td></td>
                <td></td>
            </tr>
        </table>
        <form name="frmReclamo" id="frmReclamo" action="DetalleReclamo.jsp" method="post">
            <input type="text" value="" id="codigo" name="codigo"  style="visibility: hidden;" />
        <table width="80%" border="1" cellpadding="0" cellspacing="0">
            <tr>
                <th width="15%">Nombre</th>
                <th width="15%">Ap. Paterno</th>
                <th width="15%">Ap. Materno</th>
                <th width="15%">Telefono</th>
                <th width="30%">Direccion</th>
                <th width="5%">Seleccionar</th>
            </tr>
            <%
            ConsultaDAO dao=new ConsultaDAO();
            List<Reclamo> listaReclamo = new ArrayList<Reclamo>();
            listaReclamo=dao.getListaReclamo(request.getParameter("txBusca").toString() );
            for (int row = 0; row < listaReclamo.size(); row++) {
                Reclamo oReclamo = new Reclamo();
                oReclamo = listaReclamo.get(row);
            %>
            <tr>
                <td><%=oReclamo.getNombre().toString() %></td>
                <td><%=oReclamo.getAppaterno().toString() %></td>
                <td><%=oReclamo.getApmaterno().toString() %></td>
                <td><%=oReclamo.getTelefono().toString()%></td>
                <td><%=oReclamo.getDireccion().toString()%></td>
                <td><input type="checkbox" name="reclamo" id="reclamo"  onclick="javascript: seleccionar('<%= oReclamo.getIdReclmao().toString()%>','<%=row%>');"> </td>
            </tr>
            <%
            }
            %>
        </table>
         <br><br><br>
         <input type=submit value='Ver Detalle'>
        <input type=button onClick="location.href='RegistroDeudor.jsp'" value='Registrar deudor'>
        <input type=button onClick="location.href='Reclamo.jsp'" value='Registrar Reclamo'>
        <input type=button onClick="location.href='BuscaDeudor.jsp'" value='Lista Deudor'>
        <input type=button onClick="location.href='BuscaReclamo.jsp'" value='Lista Reclamo'>
        </form>

    </body>
</html>
